//1.引入内置path模块
const path = require("path");

//2.声明路径
let filepath = "a/b/c/d.txt";

//3.path.parse(filepath) : 解析文件路径的每一部分
let p = path.parse(filepath);
console.log(p);//{ root: '', dir: 'a/b/c', base: 'd.txt', ext: '.txt', name: 'd' }

//4.path.basename(filepath) : 解析文件名
console.log(path.basename(filepath)); //d.txt

//5. path.extname(filepath) : 解析后缀
console.log(path.extname(filepath)); //.txt

//6. path.join(路径参数...) ：拼接路径，拼接正确的路径
let f = path.join("deom/a/b","\c.txt");
console.log(f); //deom\a\b\c.txt

console.log(path.join("deom/a/b",".." ,"c.txt"));//deom\a\c.txt

console.log(path.join(__dirname,"a.txt")); //E:\txf\0914three\day05_模块化开发\code\a.txt



